package 线程池.作业;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

public class 练习ConcurrentHashMap{
    public static void main(String[] args) {
        ConcurrentHashMap<String, String> hashMap = new ConcurrentHashMap<>();
        System.out.println(hashMap.isEmpty());
        hashMap.put("张三","吃面");
        hashMap.put("李四","喝水");
        hashMap.put("王五","舔碗");
        hashMap.put("赵六","吃龙虾");

        for (Map.Entry<String, String> sse : hashMap.entrySet()/*添加进集合*/) {
            //增强for遍历添加的
            System.out.println(sse.getKey()+"-"+sse.getValue());
            //打印遍历出的键和值
        }


        CopyOnWriteArrayList<String> strings = new CopyOnWriteArrayList<>();
        strings.add("想吃饭");
        strings.add("火锅");
        strings.add("太慢");
        strings.add("川菜");
        strings.add("太辣");
        strings.add("那你选");
        strings.add("随便");

        for (String s : strings) {
            System.out.println(s);
        }


        CopyOnWriteArraySet<String> strings1 = new CopyOnWriteArraySet<>();
        //去重
        System.out.println("------------------------------------------");
        strings1.add("找下马冬梅");
        strings1.add("马什么梅?");
        strings1.add("马冬梅");
        strings1.add("马冬什么?");
        strings1.add("马冬梅");
        strings1.add("什么冬梅?");
        strings1.add(".......");

        for (String s : strings1) {
            System.out.println(s);
        }
    }
}
